#include <stdio.h>
#include "e_os.h"

#include "sec_common.h"
#include "hard.h"

unsigned char des_key[] = {
		/* KEY 1 for ecb */
		0xAF,0x86,0x18,0x23,0x8C,0x94,0xA1,0x19,
		/* KEY 2 for ecb */
		0xAE,0x6D,0xE9,0x22,0xDB,0xB9,0x35,0x4D,
		/* KEY 3 for cbc */
		0xE3,0x83,0x0F,0x2F,0xF5,0x87,0x7D,0xAD,
		/* KEY 4 for cbc */
		0xB5,0x1D,0x7D,0x21,0x15,0xE7,0x0F,0x8B};
unsigned char des_key3[] = {
		/* KEY 1 for ecb */
		0xAF,0x86,0x18,0x23,0x8C,0x94,0xA1,0x19,0xAC,0x01,0x11,0x45,0xC4,0x4F,0x56,0x19,0x74,0xBA,0x18,0x69,0x5C,0xB4,0x54,0x05,
		/* KEY 2 for ecb */
		0xAE,0x6D,0xE9,0x22,0xDB,0xB9,0x35,0x4D,0xBB,0x6C,0xF9,0x42,0x71,0xB9,0x47,0xD4,0xEA,0xD6,0x9E,0x44,0x6B,0x9B,0x7B,0xD4,
		/* KEY 3 for cbc */
		0xE3,0x83,0x0F,0x2F,0xF5,0x87,0x7D,0xAD,0xEA,0xD6,0x9E,0x62,0xBD,0x9B,0x53,0xD4,0xBC,0x5C,0x49,0xDC,0xBD,0x59,0x85,0x90,
		/* KEY 4 for cbc */
		0xB5,0x1D,0x7D,0x21,0x15,0xE7,0x0F,0x8B,0xE3,0x83,0x0F,0x2F,0xF5,0x87,0x7D,0xAD,0xAE,0x6D,0xE9,0x22,0xDB,0xB9,0x35,0x4D};

unsigned char des_iv[] = {
		/* IV 1 for key 3 */
		0x38,0x32,0xF2,0x7E,0x0A,0x14,0x51,0xAF,
		/* IV 2 for key 4 */
		0x60,0x91,0x8F,0xB0,0x20,0x16,0x31,0x23};

unsigned char des_data[] = {
		/* DATA 1 for ecb */
		0xF7,0xAF,0x83,0xD4,0x98,0x7A,0x94,0x83,
		/* DATA 2 for ecb */
		0xC2,0xB7,0x71,0xDA,0x0F,0x6B,0x20,0xBE,
		/* DATA 3 for cbc */
		0x63,0x36,0x3D,0x95,0xAC,0x94,0x46,0x28,0x29,0x2D,0xB1,0x2F,0x6B,0x39,0x37,0x5C,
		/* DATA 4 for cbc */
		0x29,0xBE,0x3B,0xDF,0xE2,0x16,0xA8,0xA2,0x52,0x4F,0xE9,0x38,0x31,0xE6,0xC2,0xD2};

unsigned char des_stddata[] = {
		/* STD OUT 1 for ecb */
		0x39,0xc2,0x5b,0x99,0xd2,0x14,0xde,0x40,
		/* STD OUT 2 for ecb */
		0x09,0xa5,0x55,0xb5,0x3c,0x99,0x2a,0x33,
		/* STD OUT 3 for cbc */
		0x73,0xb8,0x13,0x1d,0x98,0x7f,0x57,0xde,0x37,0xd0,0xdb,0xa5,0x5c,0xdb,0x13,0x4d,
		/* STD OUT 4 for cbc */
		0x08,0xf5,0x60,0xe0,0xa9,0x73,0x95,0x00,0xf4,0x74,0x78,0xe3,0x05,0xd5,0x64,0xda};

unsigned char des_stddata3[] = {
		/* STD OUT 1 for ecb */
		0x4c,0xe6,0x7d,0x81,0x24,0xbd,0x02,0xb1,
		/* STD OUT 2 for ecb */
		0x7e,0x6c,0x2c,0x95,0xa3,0x50,0x9b,0x81,
		/* STD OUT 3 for cbc */
		0x15,0xa3,0x5d,0x0b,0x00,0x4e,0xbc,0x33,0x74,0x7f,0xf7,0x43,0x91,0xbe,0xf1,0x02,
		/* STD OUT 4 for cbc */
		0x1d,0x7b,0xf2,0x82,0x80,0xc7,0x84,0x82,0xfe,0x54,0x60,0xfe,0x13,0x7a,0x22,0xcd};

des_ecb_ssl_hard_test(int fd)
{
	volatile unsigned char *mem;
	struct cipher_api capi;
	unsigned int max_len = max_crypto_len;
	unsigned char *out,*dt;
	unsigned int i;

	capi.alg = DES;
	capi.type  = ECB;
	capi.as = INITFINAL;
	capi.key_len = 8;
	capi.iv_len = 16;
	capi.data_len = (( 0x10|(unsigned)(rand()) )&(max_crypto_len/2-1))&0xfffffff0 ;

	debug("max_crypto_len is 0x%x,data_len is 0x%x,key_size is 0x%x\n",max_len,capi.data_len,capi.key_len);

	mem = malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);
	out = malloc(capi.data_len);
	dt = malloc(capi.data_len);


	set_rand_mem((void *)(mem+CHEAD_SIZE),capi.key_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);

	memcpy((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);

/////////////////////////////////////////////////////////////////////////////
//enc
/////////////////////////////////////////////////////////////////////////////

	capi.opt = ENC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);


#ifdef DATA_VIEW
	debug("before ecb(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

#ifdef DATA_VIEW
	debug("\nafter ecb(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

/////////////////////////////////////////////////////////////////////////////
//dec
/////////////////////////////////////////////////////////////////////////////

	capi.opt = DEC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

	if(!memcmp((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len))
		debug("des_ecb_ssl_hard dec test ok!\n");
	else
	{
		errout("des_ecb_ssl_hard  dec test error!\n");
		fail_prosess();
	}

	free((void *)out);
	free((void *)mem);
	free((void *)dt);
}


des_ctr_ssl_hard_test(int fd)
{
	volatile unsigned char *mem;
	struct cipher_api capi;
	unsigned int max_len = max_crypto_len;
	unsigned char *out,*dt,iv_temp[32];
	unsigned int i;

	capi.alg = DES;
	capi.type  = CTR;
	capi.as = INITFINAL;
	capi.key_len = 8;
	capi.iv_len = 16*2;
	capi.data_len = (( 0x10|(unsigned)(rand()) )&(max_crypto_len/2-1))&0xfffffff0 ;

	debug("max_crypto_len is 0x%x,data_len is 0x%x,key_size is 0x%x\n",max_len,capi.data_len,capi.key_len);

	mem = malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);
	out = malloc(capi.data_len);
	dt = malloc(capi.data_len);


	set_rand_mem((void *)(mem+CHEAD_SIZE),capi.key_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);

	memcpy((void *)iv_temp,(void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	memcpy((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);


/////////////////////////////////////////////////////////////////////////////
//enc
/////////////////////////////////////////////////////////////////////////////

	capi.opt = ENC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);

/*
#ifdef DATA_VIEW
	debug("before ctr(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif
*/
	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));
/*
#ifdef DATA_VIEW
	debug("\nafter ctr(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif
*/
/////////////////////////////////////////////////////////////////////////////
//dec
/////////////////////////////////////////////////////////////////////////////

	capi.opt = DEC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);
	memcpy((void *)(mem+CHEAD_SIZE+capi.key_len),(void *)iv_temp,capi.iv_len);

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

	if(!memcmp((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len))
		debug("des_ctr_ssl_hard dec test ok!\n");
	else
	{
		errout("des_ctr_ssl_hard  dec test error!\n");
		fail_prosess();
	}

	free((void *)out);
	free((void *)mem);
	free((void *)dt);
}
des_cbc_ssl_hard_test(int fd)
{
	volatile unsigned char *mem;
	struct cipher_api capi;
	unsigned int max_len = max_crypto_len;
	unsigned char *out,*dt,iv_temp[16];
	unsigned int i;

	capi.alg = DES;
	capi.type  = CBC;
	capi.as = INITFINAL;
	capi.key_len = 8;
	capi.iv_len = 16;
	capi.data_len = (( 0x10|(unsigned)(rand()) )&(max_crypto_len/2-1))&0xfffffff0 ;

	debug("max_crypto_len is 0x%x,data_len is 0x%x,key_size is 0x%x\n",max_len,capi.data_len,capi.key_len);

	mem = malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);
	out = malloc(capi.data_len);
	dt = malloc(capi.data_len);


	set_rand_mem((void *)(mem+CHEAD_SIZE),capi.key_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);

	memcpy((void *)iv_temp,(void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	memcpy((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);


/////////////////////////////////////////////////////////////////////////////
//enc
/////////////////////////////////////////////////////////////////////////////

	capi.opt = ENC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);


#ifdef DATA_VIEW
	debug("before cbc(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

#ifdef DATA_VIEW
	debug("\nafter cbc(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

/////////////////////////////////////////////////////////////////////////////
//dec
/////////////////////////////////////////////////////////////////////////////

	capi.opt = DEC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);
	memcpy((void *)(mem+CHEAD_SIZE+capi.key_len),(void *)iv_temp,capi.iv_len);

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

	if(!memcmp((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len))
		debug("des_cbc_ssl_hard dec test ok!\n");
	else
	{
		errout("des_cbc_ssl_hard  dec test error!\n");
		fail_prosess();
	}

	free((void *)out);
	free((void *)mem);
	free((void *)dt);
}
des_ofb_ssl_hard_test(int fd)
{
	volatile unsigned char *mem;
	struct cipher_api capi;
	unsigned int max_len = max_crypto_len;
	unsigned char *out,*dt,iv_temp[16];
	unsigned int i;

	capi.alg = DES;
	capi.type  = OFB;
	capi.as = INITFINAL;
	capi.key_len = 8;
	capi.iv_len = 16;
	capi.data_len = (( 0x10|(unsigned)(rand()) )&(max_crypto_len/2-1))&0xfffffff0 ;

	debug("max_crypto_len is 0x%x,data_len is 0x%x,key_size is 0x%x\n",max_len,capi.data_len,capi.key_len);

	mem = malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);
	out = malloc(capi.data_len);
	dt = malloc(capi.data_len);


	set_rand_mem((void *)(mem+CHEAD_SIZE),capi.key_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);

	memcpy((void *)iv_temp,(void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	memcpy((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);


/////////////////////////////////////////////////////////////////////////////
//enc
/////////////////////////////////////////////////////////////////////////////

	capi.opt = ENC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);


#ifdef DATA_VIEW
	debug("before ofb(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

#ifdef DATA_VIEW
	debug("\nafter ofb(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

/////////////////////////////////////////////////////////////////////////////
//dec
/////////////////////////////////////////////////////////////////////////////

	capi.opt = DEC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);
	memcpy((void *)(mem+CHEAD_SIZE+capi.key_len),(void *)iv_temp,capi.iv_len);

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

	if(!memcmp((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len))
		debug("des_ofb_ssl_hard dec test ok!\n");
	else
	{
		errout("des_ofb_ssl_hard  dec test error!\n");
		fail_prosess();
	}

	free((void *)out);
	free((void *)mem);
	free((void *)dt);
}
des_cfb_ssl_hard_test(int fd)
{
	volatile unsigned char *mem;
	struct cipher_api capi;
	unsigned int max_len = max_crypto_len;
	unsigned char *out,*dt,iv_temp[16];
	unsigned int i;

	capi.alg = DES;
	capi.type  = CFB;
	capi.as = INITFINAL;
	capi.key_len = 8;
	capi.iv_len = 16;
	capi.data_len = (( 0x10|(unsigned)(rand()) )&(max_crypto_len/2-1))&0xfffffff0 ;

	debug("max_crypto_len is 0x%x,data_len is 0x%x,key_size is 0x%x\n",max_len,capi.data_len,capi.key_len);

	mem = malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);
	out = malloc(capi.data_len);
	dt = malloc(capi.data_len);


	set_rand_mem((void *)(mem+CHEAD_SIZE),capi.key_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	set_rand_mem((void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);

	memcpy((void *)iv_temp,(void *)(mem+CHEAD_SIZE+capi.key_len),capi.iv_len);
	memcpy((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len);


/////////////////////////////////////////////////////////////////////////////
//enc
/////////////////////////////////////////////////////////////////////////////

	capi.opt = ENC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);


#ifdef DATA_VIEW
	debug("before cfb(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

#ifdef DATA_VIEW
	debug("\nafter cfb(des) enc:\n");
	for(i=48;i<20+48;i++)
	{
		debug("%x ",mem[i]);
	}
	debug("\n");
#endif

/////////////////////////////////////////////////////////////////////////////
//dec
/////////////////////////////////////////////////////////////////////////////

	capi.opt = DEC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);
	memcpy((void *)(mem+CHEAD_SIZE+capi.key_len),(void *)iv_temp,capi.iv_len);

	ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);
	while(!(mem[3]&DDONE_MASK));

	if(!memcmp((void *)dt,(void *)(mem+CHEAD_SIZE+capi.key_len+capi.iv_len),capi.data_len))
		debug("des_cfb_ssl_hard dec test ok!\n");
	else
	{
		errout("des_cfb_ssl_hard  dec test error!\n");
		fail_prosess();
	}

	free((void *)out);
	free((void *)mem);
	free((void *)dt);
}
des_cbc_ssl_hard_key32_speed(int fd)
{
	int tcnt=100,MNUM=1000;
	volatile unsigned char *mem;
	struct cipher_api capi;
	unsigned int max_len = max_crypto_len; //16k
	unsigned char *out,*dt,iv_tmp[16];
	unsigned int i;
	struct timeval tv1,tv2;

	int cpid;
	int semval;
	int time,speed;

	capi.alg = DES;
	capi.type  = CBC;
	capi.as = INITFINAL;
	capi.key_len = 8;
	capi.iv_len = 16;
	capi.data_len = (max_crypto_len-100)&0xfffffff0;

	debug("max_crypto_len is 0x%x,data_len is 0x%x,key_size is 0x%x\n",max_len,capi.data_len,capi.key_len);

	for(i=0;i<tcnt-1;i++)
	{
		cpid = fork();
		if(cpid==0)
			break;
	}
//	printf("i = %d\n",i);
	mem= malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);

/////////////////////////////////////////////////////////////////////////////
//enc
/////////////////////////////////////////////////////////////////////////////

	capi.opt = ENC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);

	if(cpid==0)
	{
		do{
			sem_getvalue(usem->sem,&semval);
		}
		while(semval==1);
	}else{
		sem_wait(usem->sem);
		gettimeofday(&tv1, NULL);
	}

	for(i=0;i<MNUM;i++)
	{

		ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);

		while(!(mem[3]&DDONE_MASK));
	}

	sem_wait(dsem->sem);

	if(cpid==0)
	{
		free((void *)mem);
		exit(0);
	}else{
		do{
			sem_getvalue(dsem->sem,&semval);
		}
		while(semval!=(MAX_SEM_CNT-tcnt));
		gettimeofday(&tv2, NULL);
		free((void *)mem);
	}
	sem_post(usem->sem);

	for(i=0;i<tcnt;i++)
	{
		sem_post(dsem->sem);
	}

	time = (tv2.tv_sec-tv1.tv_sec)*1000000+tv2.tv_usec-tv1.tv_usec;

	speed = MNUM*tcnt*capi.data_len/time;
	speed*=8;

	spd_dbg("%s,CBC encrypt data_len %d,tcnt %d,speed is %dMbps,time %d us\n",__FILE__,capi.data_len,tcnt,speed,time);

/////////////////////////////////////////////////////////////////////////////
//dec
/////////////////////////////////////////////////////////////////////////////
	for(i=0;i<tcnt-1;i++)
	{
		cpid = fork();
		if(cpid==0)
			break;
	}

	mem= malloc(CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len);

	capi.opt = DEC;

	memcpy((void *)mem,(void *)(&capi),CHEAD_SIZE);

	if(cpid==0)
	{
		do{
			sem_getvalue(usem->sem,&semval);
		}
		while(semval==1);
	}else{
		sem_wait(usem->sem);
		gettimeofday(&tv1, NULL);
	}

	for(i=0;i<MNUM;i++)
	{
		ioctl(fd,_IOC(0x00,CCP903T_PCIE_MAGIC, ACLASS_CIPHER,CHEAD_SIZE+capi.key_len+capi.iv_len+capi.data_len),mem);

		while(!(mem[3]&DDONE_MASK));
	}
	sem_wait(dsem->sem);

	if(cpid==0)
	{
		free((void *)mem);
		exit(0);
	}else{
		do{
			sem_getvalue(dsem->sem,&semval);
		}
		while(semval!=(MAX_SEM_CNT-tcnt));
		gettimeofday(&tv2, NULL);
		free((void *)mem);
	}

	sem_post(usem->sem);
	for(i=0;i<tcnt;i++)
	{
		sem_post(dsem->sem);
	}

	time = (tv2.tv_sec-tv1.tv_sec)*1000000+tv2.tv_usec-tv1.tv_usec;

	speed = MNUM*tcnt*capi.data_len/time;
	speed*=8;

	spd_dbg("%s,CBC decrypt data_len %d,tcnt %d,speed is %dMbps,time %d us\n",__FILE__,capi.data_len,tcnt,speed,time);

}
